package com.tr1701_demo.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tr1701_demo.moder.dao.xgDAO;
import com.tr1701_demo.moder.entitys.denglu;

/**
 * Servlet implementation class xgServlet
 */
@WebServlet("/xgServlet")
public class xgServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public xgServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		String pwd = request.getParameter("newPwd");
		List<denglu> d = (List<denglu>) request.getSession().getAttribute("use");
		xgDAO x = new xgDAO();
		int i = x.getNewdaifahuo(d.get(0).getUphone(), pwd);
		System.err.println(i+"okds");
		if(i>0){
			request.getSession().invalidate();
			response.sendRedirect("jsps/geernzhongxin.jsp");
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
